n = int(input())
a = list(map(int, input().split()))
b_copy = [i for i in a]
b_copy.sort(reverse=True)
order = []
ans = 0
for i in range(len(b_copy)):
index = a.index(b_copy[i])
order.append(index+1)
ans += (b_copy[i]*i)+1
a[index] = 0
print(ans)
for i in order:
print(i, end=' ')
print()
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
int b[n];
for (int i = 0; i < n; i++){
cin >> a[i];
b[i] = i+1;
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
for (int k = j+1; k < n; k++){
if (a[j] < a[k]){
int x = a[j];
a[j] = a[k];
a[k] = x;
x = b[j];
b[j] = b[k];
b[k] = x;
}
}
}
}
int total = 0;
for (int i = 0; i < n; i++){
total += i * a[i] + 1;
}
cout << total << endl;
for (int i = 0; i < (n-1); i++){
cout << b[i] << " ";
}
cout << b[n-1] << endl;
}
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |